import { Component } from '@angular/core';
import {  NavController, NavParams,ViewController } from 'ionic-angular';
import { TextToSpeech } from '@ionic-native/text-to-speech';
/**
 * Generated class for the TexttospeechPage page.
 *
 * See https://ionicframework.com/docs/components/#navigation for more info on
 * Ionic pages and navigation.
 */


@Component({
  selector: 'page-texttospeech',
  templateUrl: 'texttospeech.html',
})
export class TexttospeechPage  {
  public chooseType='handle';
  public text='hello word';
  public showArr=[
  {
     text:'1.ionic cordova plugin add cordova-plugin-tts',
     tips:'安装平台'
    },
    {
      text:'2.cnpm install --save @ionic-native/text-to-speech',
      tips:'安装依赖'
     },
     {
       text:"3.import { TextToSpeech } from '@ionic-native/text-to-speech';",
       tips:'引入依赖'
      }
  ]
  
  constructor(
    public navCtrl: NavController, 
     public viewCtrl:ViewController, 
     public navParams: NavParams,
    public tts: TextToSpeech) {
  }
  dismiss(){
    this.viewCtrl.dismiss();
  }
  goTextToSpeech(){
    this.textToPage(this.text)
  }
  textToPage(text){
    this.tts.speak(text)
    .then(() => console.log('Success'))
    .catch((reason: any) => console.log(reason));
  }
  segmentChanged(e){
    console.log(e)
    console.log(this.chooseType)
  }
  ionViewDidEnter() {
    console.log('ionViewDidLoad TexttospeechPage');
    this.textToPage('欢迎进入语音播报')
  }

}
